package com.uzai.common.enums;

/**
 * 淘宝订单类型
 * @author liuqi
 * @date 2021/8/27 17:19
 * @param
 * @return null
 */
public enum TbOrderTypeEnum {
    TB(0,"淘宝"),
    TMALL(1,"天猫"),
    JHS(2,"聚划算"),
    ELM(3,"饿了么"),
    FREE(4,"免单"),
    TBT(5,"淘宝特价版"),
    SUPER_RED(6,"超红订单"),
    TARGETED_GOODS(10,"定向商品"),
    ;

    private Integer value;
    private String desc;

    TbOrderTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static TbOrderTypeEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (TbOrderTypeEnum type: TbOrderTypeEnum.values()) {
            if (type.getValue().intValue() == id) {
                return type;
            }
        }
        return null;
    }

    public static TbOrderTypeEnum getByDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (TbOrderTypeEnum type: TbOrderTypeEnum.values()) {
            if (type.getDesc().equals(desc)) {
                return type;
            }
        }
        return null;
    }
}
